home *** CD-ROM | disk | FTP | other *** search
/ LiquidLibrary 2005 September / LiquidLibrary 2005 Sep - Disc 1.iso / pc / Portfolio Browser / Filters / PDF / LIB / gsnup.ps < prev    next >
Text File  |  2003-01-03  |  2KB  |  79 lines

  1. %!
  2. %    Copyright (C) 1999 Aladdin Enterprises.  All rights reserved.
  3. % This software is licensed to a single customer by Artifex Software Inc.
  4. % under the terms of a specific OEM agreement.
  5.  
  6. % $RCSfile$ $Revision$
  7. % Prefix this to very well-behaved PostScript files for n-up printing.
  8.  
  9. /cdef { 1 index where { pop pop } { def } ifelse } def
  10.  
  11. %%%%%%%%%%%%%%%% Begin parameters %%%%%%%%%%%%%%%%
  12.  
  13. % All parameters are also settable from the command line with -d, e.g.,
  14. % -d.Nx=3
  15.  
  16. /.Nx 2 cdef            % # of pages across the physical page
  17. /.Ny 2 cdef            % # of pages down the physical page
  18. /.Landscape false cdef        % if true, rotate page by 90 degrees
  19.  
  20. %%%%%%%%%%%%%%%% End parameters %%%%%%%%%%%%%%%%
  21.  
  22. vmstatus pop pop 0 eq { save pop } if
  23. .Landscape {
  24.   currentpagedevice /PageSize get aload pop
  25.   exch 2 array astore
  26.   1 dict dup /PageSize 4 -1 roll put
  27.   setpagedevice
  28. } if
  29. /.BP currentpagedevice /BeginPage get def
  30. /.EP currentpagedevice /EndPage get def
  31. /.Ps 1 string def    % survive save/restore
  32. /.Pn { .Ps 0 get } def
  33. true setglobal        % protect from restore
  34. /.ELevel [0] def
  35. /.Rmat matrix def
  36. false setglobal
  37. /.max { 2 copy lt { exch } if pop } cdef
  38. % Work around the common save ... showpage ... restore locution.
  39. /restore {
  40.   .Rmat currentmatrix pop restore
  41.   vmstatus pop pop .ELevel 0 get lt { .Rmat setmatrix } if
  42. } bind def
  43. <<
  44.   /BeginPage {
  45.     .BP .Nx .Ny .max
  46.     gsave
  47.       initclip clippath pathbbox exch 4 -1 roll sub 3 1 roll exch sub
  48.     grestore
  49.     2 copy exch .Nx div exch .Ny div
  50.     .Pn dup .Nx mod exch .Nx idiv .Ny 1 sub exch sub
  51.         % Stack: nmax pw ph pw/nx ph/ny ix iy
  52.     exch 3 index mul exch 2 index mul
  53.     translate
  54.         % Stack: nmax pw ph pw/nx ph/ny
  55.     4 -1 roll 4 index div 4 -1 roll 4 index div
  56.         % Stack: nmax pw/nx ph/ny pw/nmax ph/nmax
  57.     exch 4 -1 roll exch sub 2 div
  58.     3 1 roll sub 2 div
  59.     translate
  60.         % Stack: nmax
  61.     1 exch div dup scale
  62.   }
  63.   /EndPage {
  64.     .ELevel 0 vmstatus pop pop put
  65.     .Ps 0 .Pn 1 add .Nx .Ny mul mod put    
  66.     .Pn 0 eq {
  67.       .EP
  68.     } {
  69.       pop pop false
  70.     } ifelse
  71.   }
  72. >> setpagedevice
  73. /.EOJ {
  74.   { .Pn 0 eq { exit } if showpage } loop
  75. } def
  76.  
  77. { currentfile cvx exec .EOJ } exec
  78.